import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import resolve from "path";
import ViteCompression from "vite-plugin-compression";

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    react(),
    ViteCompression(
      {
        algorithm:'gzip'
      }
    ),
    {
      name:'my-puling',
      transform(code){
        return code.replace(/consele.log/g,'/console.info')
      }
    }

  ],
  
  resolve:{
    alias:{
      "@":resolve.resolve(__dirname,"src")

    }
  },
  server:{
    proxy:{
      '/api':{
        target:"http://172.27.2.110/",
        changeOrigin:true,
        rewrite:(path)=>path.replace(/^\/api/,'')
      }
    }
  },
  build:{
    outDir:'dist',
    rollupOptions:{
      output:{
        chunkFileNames:'[name].[hash].js',
        entryFileNames:'[name].[hash].js',
        assetFileNames:'[name].[hash].[ext]'
      }
    }
  },
  // esbuild:{
  //   drop:['console','debugger']
  // }
  
})
